package net.wds.ssbus.modules.dbconfig.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import net.wds.ssbus.common.utils.PageUtils;
import net.wds.ssbus.common.utils.R;
import net.wds.ssbus.modules.dbconfig.entity.TbDbSourceConfigPoolEntity;
import net.wds.ssbus.modules.dbconfig.service.TbDbSourceConfigPoolService;
import net.wds.ssbus.modules.dbconfig.vo.DbSourceConfigPoolVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




/**
 *  
 *
 * @author qsg
 * @email qsg@wdsrouce
 * @date 2020-10-22 11:41:56
 */
@RestController
@RequestMapping("dbconfig/tbdbsourceconfigpool")
public class TbDbSourceConfigPoolController {
    @Autowired
    private TbDbSourceConfigPoolService tbDbSourceConfigPoolService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("ssbus:tbdbsourceconfigpool:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tbDbSourceConfigPoolService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 所有数据源配置列表
     */
    @RequestMapping("/listall/{dbId}/{dbTypeId}")
    //@RequiresPermissions("ssbus:tbdbsourceconfigpool:list")
    public R listAll(@PathVariable("dbId") Integer dbId, @PathVariable("dbTypeId") Integer dbTypeId){
        List<DbSourceConfigPoolVo> list = tbDbSourceConfigPoolService.getList(dbId, dbTypeId);

        return R.ok().put("list", list);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("ssbus:tbdbsourceconfigpool:info")
    public R info(@PathVariable("id") Integer id){
		TbDbSourceConfigPoolEntity tbDbSourceConfigPool = tbDbSourceConfigPoolService.getById(id);

        return R.ok().put("tbDbSourceConfigPool", tbDbSourceConfigPool);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("ssbus:tbdbsourceconfigpool:save")
    public R save(@RequestBody TbDbSourceConfigPoolEntity tbDbSourceConfigPool){
		tbDbSourceConfigPoolService.save(tbDbSourceConfigPool);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("ssbus:tbdbsourceconfigpool:update")
    public R update(@RequestBody TbDbSourceConfigPoolEntity tbDbSourceConfigPool){
		tbDbSourceConfigPoolService.updateById(tbDbSourceConfigPool);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("ssbus:tbdbsourceconfigpool:delete")
    public R delete(@RequestBody Integer[] ids){
		tbDbSourceConfigPoolService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
